<?php
function addmenu($name,$file,$title){
	$query="UPDATE environnement SET lastmod=NOW()";
	@rportalrequete($query) or rportalerreur($query,"?op=admmenuliste");
	$query = "INSERT INTO rportal_menu (nom,titre,fichier) VALUES ('".$name."','".addslashes($title)."','".$file."')";
	$res=@rportalrequete($query) or rportalerreur ("$query","?op=");
	return rportallastid($res);
}
function additem($menuid,$texte,$lien,$target,$ordre,$droit){
	$query = "INSERT INTO rportal_menu_item (id_menu,texte,lien,target,ordre) VALUES ('".$menuid."','".addslashes($texte)."','".$lien."','".$target."','".$ordre."')";
	$res=@rportalrequete($query) or rportalerreur ("$query","?op=");
	if(is_array($droit)){
		if(count($droit)>0){
			$itemid = rportallastid($res);
			for($i=0;$i<count($droit);$i++){
				$query = "INSERT INTO rportal_menu_droit (id_menu,id_item,fonction) VALUES ('".$menuid."','".$itemid."','".$droit[$i]."')";
				@rportalrequete($query) or rportalerreur ("$query","?op=");
			}
		}
	}
}
/**
 * Menu Contenu
 */
$menuid = addmenu("Contenu","adm.html","CONTENU");
$droit = array();
$droit[0] = "admhtmlnav";
additem($menuid,"Navigateur","?op=admhtmlnav","","1",$droit);
$droit = array();
$droit[0] = "admhtmlsauv";
additem($menuid,"Sauvegarder","?op=admhtmlsauv","","2",$droit);
$droit = array();
$droit[0] = "admhtmlcharger";
additem($menuid,"Charger","?op=admhtmlcharger","","3",$droit);
$droit = array();
$droit[0] = "admhtmlindexall";
additem($menuid,"Tout indexer","?op=admhtmlindexall","","4",$droit);
/**
 * Menu email
 */
$menuid = addmenu("email","email","EMAIL TYPE");
$droit = array();
$droit[0] = "admemailliste";
additem($menuid,"Liste des emails","?op=admemailliste","","1",$droit);
$droit = array();
$droit[0] = "admemailadd";
additem($menuid,"Ajouter un email","?op=admemailadd&eid=-1","","2",$droit);
$droit = array();
additem($menuid,"Notifications","?op=admnotifliste","","3",$droit);

/**
 * Menu environnement
 */
$menuid = addmenu("environnement","adm.environnement","ENVIRONNEMENT");
$droit = array();
additem($menuid,"liste","?op=admenvliste","","1",$droit);
$droit = array();
$droit[0] = "admenvnew";
additem($menuid,"Ajouter un environnement","?op=admenvnew","","2",$droit);
$droit = array();
$droit[0] = "admenvboxtypeliste";
additem($menuid,"Types de box","?op=admenvboxtypeliste","","3",$droit);
$droit = array();
$droit[0] = "admenvchg";
additem($menuid,"changer d'environnement","?op=admenvchg","","4",$droit);

/**
 * Menu fonction
 */
$menuid = addmenu("fonction","adm.fonction","FONCTIONS");
$droit = array();
$droit[0] = "admfoncliste";
additem($menuid,"Liste","?op=admfoncliste","","1",$droit);
$droit = array();
$droit[0] = "admfoncnew";
additem($menuid,"Ajouter une fonction","?op=admfoncnew","","2",$droit);
$droit = array();
$droit[0] = "admfoncsauvscript";
additem($menuid,"Sauvegarder","?op=admfoncsauvscript","","3",$droit);
$droit = array();
$droit[0] = "admmaskgest";
additem($menuid,"Masques de droit","?op=admmaskgest","","4",$droit);

/**
 * Menu groupe
 */
$menuid = addmenu("groupe","adm.groupe","GROUPES");
$droit = array();
$droit[0] = "admgroupliste";
additem($menuid,"Liste","?op=admgroupliste","","1",$droit);
$droit = array();
$droit[0] = "admgroupnew";
additem($menuid,"Ajouter un groupe","?op=admgroupnew","","2",$droit);

/**
 * Menu inscription
 */
$menuid = addmenu("inscription","adm.inscription","INSCRIPTIONS");
$droit = array();
$droit[0] = "adminscliste";
additem($menuid,"Demandes d'inscription","?op=adminscliste","","1",$droit);
$droit = array();
$droit[0] = "adminscgroup";
additem($menuid,"Parametres d'inscription","?op=adminscgroup","","2",$droit);

/**
 * Menu intranet
 */
$menuid = addmenu("intranet","adm.intranet","INTRANET");
$droit = array();
$droit[0] = "admintraip";
additem($menuid,"Zone IP","?op=admintraip","","1",$droit);

/**
 * Menu menu
 */
$menuid = addmenu("menu","menu","MENU");
$droit = array();
$droit[0] = "admmenuliste";
additem($menuid,"Liste des menus","?op=admmenuliste","","1",$droit);
$droit = array();
$droit[0] = "admmenuadd";
additem($menuid,"Nouveau menu","?op=admmenuadd","","2",$droit);
$droit = array();
$droit[0] = "admmenusauv";
additem($menuid,"Sauvegarder","?op=admmenusauv","","3",$droit);

/**
 * Menu plugin
 */
$menuid = addmenu("plugin","plugin","PLUGIN");
$droit = array();
additem($menuid,"Liste des plugins","?op=admplugliste","","1",$droit);

/**
 * Menu sequenceur
 */
$menuid = addmenu("sequenceur","adm.sequenceur","SEQUENCEUR");
$droit = array();
$droit[0] = "admseqliste";
additem($menuid,"Liste des sequences","?op=admseqliste","","1",$droit);
$droit = array();
$droit[0] = "admseqnew";
additem($menuid,"nouvelle sequence","?op=admseqnew","","2",$droit);
$droit = array();
$droit[0] = "admseqetaliste";
additem($menuid,"scripts du sequenceur","?op=admseqetaliste","","3",$droit);
$droit = array();
additem($menuid,"Sauvegarder","?op=admseqsauv","","4",$droit);

/**
 * Menu session
 */
$menuid = addmenu("session","adm.session","SESSIONS");
$droit = array();
$droit[0] = "admsessliste";
additem($menuid,"Liste","?op=admsessliste","","1",$droit);
$droit = array();
$droit[0] = "admsesspurge";
additem($menuid,"Purger","?op=admsesspurge","","2",$droit);

/**
 * Menu utilisateur
 */
$menuid = addmenu("utilisateur","adm.utilisateur","UTILISATEURS");
$droit = array();
$droit[0] = "admuserliste";
additem($menuid,"Liste","?op=admuserliste","","1",$droit);
$droit = array();
$droit[0] = "admusernew";
additem($menuid,"Nouvel utilisateur","?op=admusernew","","2",$droit);
$droit = array();
$droit[0] = "admuserarchall";
additem($menuid,"Archiver tous","?op=admuserarchall","","3",$droit);
$droit = array();
$droit[0] = "admuserarchpurge";
additem($menuid,"purger les archives","?op=admuserarchpurge","","4",$droit);


?>